package com.ciquan.server.job;

import com.ciquan.server.bean.UnReply;
import com.ciquan.server.service.MessageService;
import com.ciquan.server.service.PhoneCodeService;
import com.ciquan.server.util.DateUtils;
import org.apache.log4j.Logger;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by card on 15/10/10.
 */
public class UnReplyMessageJob {

    private Logger logger = Logger.getLogger(this.getClass().getName());

    @Resource
    private MessageService messageService;

    @Resource
    private PhoneCodeService phoneCodeService;

    public void execute() {
        logger.info("---------------------开始执行UnReadMessageJob---------------------");

        String starTime = DateUtils.miniute(-2);
        String endTime = DateUtils.miniute(-1);
        List<UnReply> unReplies = messageService.unReply(starTime, endTime);

        for (UnReply unReply : unReplies) {
            unReply.setTime(starTime);
            phoneCodeService.unReply(unReply);
        }

        logger.info("---------------------UnReadMessageJob执行结束 发送消息数量" + unReplies.size() + "---------------------");
    }
}
